import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/Home/Home'
import Activity from '@/pages/Activity/Activity'
import Comment from '@/pages/Comment/Comment'
import Detail from '@/pages/Detail/Detail'
import Consult from '@/pages/Consult/Consult'
import Register from '@/pages/Register/Register'
import AddComment from '@/pages/Interact/AddComment'
import Interact from '@/pages/Interact/Interact'
import Participant from '@/pages/Interact/Participant'
import Author from '@/common/Author/Author'
import Coupon from '@/pages/Coupon/coupon'
import Letter from '@/pages/Letter/letter'
import Letterdetail from '@/pages/Letterdetail/letterdetail'
import Merchant from '@/pages/Merchant/merchant'
import Personal from '@/pages/Personal/personal'
import Setinfo from '@/pages/Setinfo/setinfo'
import makefriend from '@/pages/makefriends/makefriend'
import share from '@/pages/share/share'



Vue.use(Router)


export default new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
      meta: {
        title: '首页'
      }
    },{
      path: '/Activity',
      name: 'Activity',
      component: Activity,
      meta: {
        title: '我的活动'
      }
    },{
      path: '/Comment/:id',
      name: 'Comment',
      component: Comment,
      meta: {
        title: '评论活动'
      }
    },{
      path: '/Detail/:id',
      name: 'Detail',
      component: Detail,
      meta: {
        title: '活动'
      }
    },{
      path: '/Consult',
      name: 'Consult',
      component: Consult
    },{
      path: '/Register',
      name: 'Register',
      component: Register,
      //这个页面只能从详细页进去 并且带有参数 否则退出
      beforeEnter: (to, from, next) => {
        if(from.name !== 'Detail' && from.name !== 'Register') {
          next('/')
        }else{
          next()
        }
      },
      meta: {
        title: '报名'
      }
    },{
      path: '/AddComment/:id',
      name: 'AddComment',
      component: AddComment,
      meta: {
        title: '添加互动'
      }
    },{
      path: '/Interact/:id',
      name: 'Interact',
      component: Interact,
      meta: {
        title: '活动互动'
      }
    },{
      path: '/Participant/:id',
      name: 'Participant',
      component: Participant,
      meta: {
        title: '参与人'
      }
    },{
      path: '/Author',
      name: "Author",
      component: Author,
      meta: {
        title: '正在登录'
      }
    },{
      path: '/Coupon',
      name: "Coupon",
      component: Coupon,
      meta: {
        title: '我的优惠券'
      }
    },{
      path: '/Letter',
      name: "Letter",
      component: Letter,
      meta: {
        title: '我的私信'
      }
    },{
      path: '/Letterdetail',
      name: "Letterdetail",
      component: Letterdetail,
      meta: {
        title: '我的私信'
      }
    },{
      path: '/Merchant',
      name: "Merchant",
      component: Merchant,
    },{
      path: '/Personal/:id',
      name: 'Personal',
      component: Personal
    },{
      path: '/Setinfo/:userid',
      name: 'Setinfo',
      component: Setinfo,
      meta: {
        title: '我的资料'
      }
    },{
      path: '/makefriend',
      name: 'makefriend',
      component: makefriend,
      meta: {
        title: '交友首页'
      }
    },{
      path: '/share',
      name: 'share',
      component: share,
      meta: {
        title: '二维码分享关注'
      }
    }
  ],
  scrollBehavior (to, from, savedPosition) {
      return { x: 0, y: 0 }
  }
})
